package com.yyk.yykywd.mvvm.view_model

import androidx.lifecycle.MutableLiveData
import com.yyk.yykywd.mvvm.entity.DynamicBroadcastBean
import com.yyk.yykywd.mvvm.entity.HomeBean
import com.yyk.yykywd.mvvm.model.HomeModel

/**
 * 文件描述：
 * Created by guo on 2019-11-27.
 */
class DynamicBroadcastViewModel : BaseViewModel() {
    var id: String = ""
    var reports: MutableList<DynamicBroadcastBean.Data> = ArrayList()

    private val homeModel = HomeModel()
    //LiveData,使该数据可以被感知
    var dynamicBroadcast = MutableLiveData<DynamicBroadcastBean>()

    fun getReport() {
        homeModel.getReports(id, page.toString(), num.toString(), object : HomeModel.GetReport {
            override fun getInfo(report: DynamicBroadcastBean) {
                if (isClear) {
                    reports.clear()
                    isClear = false
                }
                reports.addAll(report.data)
                dynamicBroadcast.value = report
            }

            override fun onError(e: String) {

            }

        })
    }
}